﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;

namespace Company.Core.Helpers
{

    /// <summary>
    /// 断言类型，判断参数对象是否为空
    /// </summary>
    public static class Assert
    {
        /// <summary>
        /// 不允许为空，为空则抛出异常
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="obj"></param>
        /// <param name="callerMemberName"></param>
        /// <exception cref="ArgumentNullException"></exception>
        public static void NotNull<T>(T obj, [CallerMemberName] string callerMemberName = null)
        {
            if (obj == null)
            {
                throw new ArgumentNullException($"参数 {typeof(T)} 不能为空，调用方法{callerMemberName}");
            }
        }
    }
}
